


str1 = "A10;S20;W10;D30;X;A1A;B10A11;;A10;"
str2 = str1.split(";")
x, y = 0, 0
for r in str2:
    if len(r) > 3 or len(r) < 2:
        continue
    elif r[1:].isdigit():
        if r[0] == "A":
            r = r[1:]
            x = x - int(r)
        elif r[0] == "S":
            r = r[1:]
            y -= int(r)
        elif r[0] == "W":
            r = r[1:]
            y += int(r)
        elif r[0] == "D":
            r = r[1:]
            x+=int(r)
    else:
        continue
print(f"{x},{y}")


